/**
 * Copyright (C), 2015-2019, bogewang
 * FileName: SessionConfig
 * Author:   foren236598164@aliyun.com
 * Date:     2019/9/30 16:42
 * Description: SessionConfig
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bogewang.session.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.session.data.redis.config.ConfigureRedisAction;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * 〈SessionConfig〉
 *
 * @author foren236598164@aliyun.com
 * @create 2019/9/30
 * @since 1.0.0
 */
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 1800)
public class SessionConfig {
    @Value("${redis.hostname}")
    String hostName;
    @Value("${redis.port}")
    int port;
    @Value("${redis.password}")
    String passWord;

    @Bean
    public JedisConnectionFactory connectionFactory(){
        JedisConnectionFactory connection = new JedisConnectionFactory();
        connection.setPort(port);
        connection.setHostName(hostName);
        connection.setPassword(passWord);
        return connection;
    }

    @Bean
    public static ConfigureRedisAction configureRedisAction() {
        return ConfigureRedisAction.NO_OP;
    }
}